package com.hitqz.robot.biz.flow.component.agv;

import cn.hutool.json.JSONObject;
import com.hitqz.robot.biz.flow.domain.constant.FlowConstant;
import com.hitqz.robot.biz.flow.util.LiteFlowUtil;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.client.RestTemplate;

/**
 * @author xupkun
 * @date 2025/4/5
 */
@Slf4j
@LiteflowComponent(value = "UpdateStoreStatus", name = "[轮对/轮轴]轮对更新缓存架状态")
@AllArgsConstructor
public class UpdateStoreStatus extends NodeComponent {

    private final RestTemplate restTemplate;

    @Override
    public void process() throws Exception {
        LiteFlowUtil.checkInterruptFlag();
        String uri = this.getCmpData(JSONObject.class).get(FlowConstant.NODE_CUSTOM_INFO_MAP.get(this.getNodeId()).getParamNames().get(0), String.class).trim();
        String result = restTemplate.postForObject(uri, "", String.class);
        log.info("更新 {}---结果是:{}", uri, result);
    }
}
